package com.shui_shui;

import com.shui_shui.compass.Degree;

import android.app.Activity;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.ImageView;

public class CompassShowActivity extends Activity implements OnTouchListener{

	private ImageView showCompass;
	private ImageView back;	
	private ImageView help; 

	@Override
	public void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		setContentView(R.layout.showcompass);

		showCompass = (ImageView) findViewById(R.id.compassshow);

		Resources res = getResources();
		String mDrawableName = Degree.getDegree().getImageHome();
		int resID = res.getIdentifier(mDrawableName, "drawable",
				getPackageName());
		Drawable drawable = res.getDrawable(resID);
		showCompass.setImageDrawable(drawable);
		
		back = (ImageView) findViewById(R.id.back);
		help = (ImageView) findViewById(R.id.help);
		
		back.setOnTouchListener(this);
		help.setOnTouchListener(this);
	}

	
	@SuppressWarnings("deprecation")
	public boolean onTouch(View v, MotionEvent event) {
		switch (v.getId()) {        
		case R.id.back:            
			switch (event.getAction()) {            
			case MotionEvent.ACTION_DOWN:            
				back.setAlpha(150);                
				break;            
			case MotionEvent.ACTION_UP:            
				back.setAlpha(255);	
				this.finish();
				break;            
			default:                
				break;            
			}            
			break;        
		case R.id.help:            
			switch (event.getAction()) {            
			case MotionEvent.ACTION_DOWN:            
				help.setAlpha(150);                
				break;            
			case MotionEvent.ACTION_UP:            
				help.setAlpha(255);                
				break;            
			default:                
				break;            
			}            
			break; 
		}        
		return true;
	}

}
